package com.zhu.salesmanagement.network;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.xmlrpc.android.XMLRPCClient;

import com.zhu.salesmanagement.common.Actions;

import android.util.Log;

public class PostMethod {

	public static final String CALL_LOGIN = "dmsmobile.getSalesperson";
	public static final String CALL_PRODUCTCATEGORY = "dmsmobile.getProductCategory";
	public static final String CALL_PRODUCT= "dmsmobile.getProduct";
	public static final String CALL_REMIND = "dmsmobile.getRemindMSG";
	public static final String CALL_CUSTOMER= "dmsmobile.getCustomer";
	public static final String CALL_CUSTOMERSHELF= "dmsmobile.getProductCategoryAndCustomerShelfOfCustomers";
	public static final String CALL_UPDATECUSTOMERSHELF= "dmsmobile.getProductCategoryOfCustomers";
	public static final String CALL_TASKLIST = "dmsmobile.getDatingTaskList";
	public static final String POST_ADDEDNEWSTORES = "dmsmobile.putCustomerTemp";
	public static final String POST_CUSTOMERSHELF= "dmsmobile.putCustomerShelf";
	public static final String POST_VISITEDTASK = "dmsmobile.putDatingTaskActual";
	public static final String POST_VISITEDTASKCRC = "dmsmobile.putDatingTaskActualCRC";
	public static final String POST_VISITEDTASKOTHER = "dmsmobile.putDatingTaskActualOther";
	public static final String POST_CUSTOMERCLOSE= "dmsmobile.putCustomerClosed";
	public static final String POST_COMPLETETED= "dmsmobile.isCompleted";

	public static void requesLogin(String name, String password, boolean isFirst, String version, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_LOGIN, callback, client);
    	if(Actions.DEBUG){
    		Log.e("zhu","isFirst="+isFirst);
    	}
    	Object[] params = { name, password, isFirst ? 1 : 0, version};
        method.call(params);
	}

	public static void requesCustomer(String eid, String uuid, boolean isFirst, XMLRPCMethodCallback callback, XMLRPCClient client){
        XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_CUSTOMER, callback, client);
        Object[] params = new Object[]{ eid, uuid};
        method.call(params);
    }

	public static void requesProductCategory(String eid, String uuid, boolean isFirst, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_PRODUCTCATEGORY, callback, client);
    	Object[] params = { eid, uuid };
        method.call(params);
	}

	public static void requesProducts(String eid, String uuid, boolean isFirst, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_PRODUCT, callback, client);
    	Object[] params = { eid, uuid };
        method.call(params);
	}

	public static void requesCustomerShelfs(String eid, String uuid, boolean isFirst, XMLRPCMethodCallback callback, XMLRPCClient client){
        XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_CUSTOMERSHELF, callback, client);
        Object[] params = { eid, uuid };
        method.call(params);
    }

	public static void requesUpdateCustomerPC(String eid, String uuid, boolean isFirst, XMLRPCMethodCallback callback, XMLRPCClient client){
        XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_UPDATECUSTOMERSHELF, callback, client);
        Object[] params = { eid, uuid };
        method.call(params);
    }

	public static void requesMyTaskList(String eid, String uuid, XMLRPCMethodCallback callback, XMLRPCClient client){
        XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_TASKLIST, callback, client);
        Object[] params = { eid, uuid };
        method.call(params);
    }


	public static void requesRemindMsg(String eid, String uuid, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_REMIND, callback, client);
    	Object[] params = { eid, uuid };
        method.call(params);
	}

	public static void postNewStores(String eid, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.CALL_REMIND, callback, client);
    	 Map<String, Object> map = new HashMap<String, Object>();
         map.put("sEmployeeID", eid);
    	Object[] params = { map };
        method.call(params);
	}

	public static void postCustomerShelf(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_CUSTOMERSHELF, callback, client);
        method.call(params);
	}

	public static void postDatingTaskActual(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_VISITEDTASK, callback, client);
        method.call(params);
	}

	public static void postDatingTaskActualCRC(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_VISITEDTASKCRC, callback, client);
        method.call(params);
	}
	
	public static void postDatingTaskActualOther(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_VISITEDTASKOTHER, callback, client);
        method.call(params);
	}

	public static void postNewAddedStores(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_ADDEDNEWSTORES, callback, client);
        method.call(params);
	}

	public static void postCustomerClose(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_CUSTOMERCLOSE, callback, client);
        method.call(params);
	}

	public static void postCompeleted(Object[] params, XMLRPCMethodCallback callback, XMLRPCClient client){
    	XMLRPCMethod method = new XMLRPCMethod(PostMethod.POST_COMPLETETED, callback, client);
        method.call(params);
	}
}
